package game;

import java.awt.Color;

public class Elevator extends Platform {
	public static final long serialVersionUID = 1L;
	protected int moveHeight;
	protected int moveSpeed;
	protected boolean movingUp;
	protected int org;
	
	public Elevator(){}
	
	public Elevator(Level g, int x, int y, int w, int h, Color c, int mh, int s){
		super(g, x, y, w, h, c);
		moveHeight = mh;
		moveSpeed = s;
		movingUp = true;
		org = y;
		downMotion = -moveSpeed;
	}
	
	@Override
	public void update(){
		prevY = y;
		if(movingUp){
			y -= moveSpeed;
			if(y < org - moveHeight){
				y = org - moveHeight;
				movingUp = false;
				downMotion = moveSpeed;
			}
		}else{
			y += moveSpeed;
			if(y > org){
				y = org;
				movingUp = true;
				downMotion = -moveSpeed;
			}
		}
	}
}
